package com.mobjam.workingtitleforagame;

import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;

public class MapActivity extends Activity {
	protected GestureDetector gestureScanner;
	protected ScaleGestureDetector scaleGestureScanner;
	protected Date date;
	protected int X;
	protected int Y;
	protected MapControl mapControl;
	protected MapView mapView;
	protected Map gameMap;

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		if( !gestureScanner.onTouchEvent(event) && !scaleGestureScanner.onTouchEvent( event ) )
		{
			return super.onTouchEvent(event);
		}

		return true;
	}
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    
	    // load up static resources
	    MapObject.loadBitmaps(this);
	    MapTile.loadBitmaps(this);
	    
	    mapView = new MapView( this );
	    setContentView(mapView);
	    mapControl = new MapControl( this, mapView);
	    gestureScanner = new GestureDetector(mapControl);
	    //gestureScanner.setIsLongpressEnabled(false);
	    scaleGestureScanner = new ScaleGestureDetector( this, mapControl );
	}
	
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_map, menu);
        return true;
    }

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		mapView.restartAnimation();
	}

	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		// TODO Auto-generated method stub
		switch( item.getItemId() )
		{
			case R.id.menu_settings:
            	Intent myIntent = new Intent( this, CharacterManagementActivity.class);
                startActivityForResult(myIntent, 0); 
				return true;
			default:
				return super.onOptionsItemSelected(item);
		}
	}
    
    

}
